package com.shenhaofeng.permission;

import android.support.annotation.NonNull;
import android.support.v7.app.AppCompatActivity;

import com.shenhaofeng.permissions.PermissionsRequester;
import com.shenhaofeng.permissions.PermissionsResultSource;
import com.shenhaofeng.permissions.PermissionsSource;

/**
 * Created by haofeng on 2016/9/25.
 */

public class BaseActivity extends AppCompatActivity implements PermissionsSource {


    private PermissionsResultSource mPermissionsResultSource;

    @Override
    public void onBindRequestPermissionsResultSource(PermissionsResultSource requester) {
        this.mPermissionsResultSource = requester;
    }


    @Override
    public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
        super.onRequestPermissionsResult(requestCode, permissions, grantResults);
        if (mPermissionsResultSource != null && mPermissionsResultSource.getRequestCode() == requestCode) {
            mPermissionsResultSource.onRequestPermissionsResult(requestCode, permissions, grantResults);
        }
    }

}
